clear

use "$dir\HH_replication_2023_EDCC_Keefer_Khemani.dta", clear

*RHScommon includes controls for all ethnic groups (4) reported by more than 10% of respondents
global RHScommon_all "num_public num_ccial_private num_religious age_resp resp_female elementary secondary higher_resp bariba yom ditamari yoruba peulh dendi adja fon num_adults num_over_60 num_children num_children_0_5  gender_head age_head single_resp polygamous_resp islam catholic inc_30k brick_wall cement_floor rooms_over5 own_radio own_tv own_mobile pop_vil dist_city3 dist_stop prv_school_fcnl chief_primary chief_geq_secondary paved_road sec_school lit_ctr health_ctr potable_src same_mx_l1 similar_l1_vil"
global RHScommon "num_public num_ccial_private num_religious age_resp resp_female elementary secondary higher_resp bariba yom ditamari yoruba num_adults num_over_60 num_children num_children_0_5  gender_head age_head single_resp polygamous_resp islam catholic inc_30k brick_wall cement_floor rooms_over5 own_radio own_tv own_mobile pop_vil dist_city3 dist_stop prv_school_fcnl chief_primary chief_geq_secondary paved_road sec_school lit_ctr health_ctr potable_src same_mx_l1 similar_l1_vil"
global RHScommon_nokids "num_public num_ccial_private num_religious age_resp resp_female elementary secondary higher_resp bariba yom ditamari yoruba num_adults num_over_60 gender_head age_head single_resp polygamous_resp islam catholic inc_30k brick_wall cement_floor rooms_over5 own_radio own_tv own_mobile pop_vil dist_city3 dist_stop prv_school_fcnl chief_primary chief_geq_secondary paved_road sec_school lit_ctr health_ctr potable_src same_mx_l1 similar_l1_vil"
global RHScommon_HH "age_resp resp_female elementary secondary higher_resp bariba yom ditamari yoruba num_adults num_over_60 num_children num_children_0_5  gender_head age_head single_resp polygamous_resp islam catholic inc_30k brick_wall cement_floor rooms_over5 own_radio own_tv own_mobile"

gen num_children_radio = num_children*num_nonccial_private

label var num_nonccial_private "Number of private non-commercial stations"
label var num_public "Number of public stations"
label var num_ccial_private "Number of private commercial stations"
label var num_religious "Number of religious stations"

gen HH_lstn_priv_noncom =(num_pvt_noncomm_radio_lstn>=1)
gen nonccial_2=(num_nonccial_private>1)
gen nonccial_3=(num_nonccial_private>2)


*TABLE 1 ACCESS TO RADIO SATIONS(FROM BEDNETS PAPER)

*APPENDIX TABLE A.1.  Balance table.  

foreach RHSvar in $RHScommon {
areg num_nonccial_private `RHSvar', absorb(comid) cluster(villageid) 
		}
areg num_nonccial_private $RHScommon, absorb(comid) cluster(villageid)

*REPORTED IN TEXT, Balance table excluding non-respondents to the jobs_health and jobs_edu questions.
gen respond_health=1 if jobs_v_health~=.
	replace respond_health=0 if jobs_v_health==.
gen respond_edu=1 if jobs_v_edu~=.
	replace respond_edu=0 if jobs_v_edu==.

foreach RHSvar in $RHScommon {
	areg num_nonccial_private `RHSvar', absorb(comid) cluster(villageid)	
	areg num_nonccial_private `RHSvar' if respond_health==1, absorb(comid) cluster(villageid)	
	areg num_nonccial_private `RHSvar' if respond_edu==1, absorb(comid) cluster(villageid)	
	}

*REPORTED IN TEXT:  No differences between respondents and non-respondents 
foreach RHSvar in $RHScommon {
	des `RHSvar'
	ttest `RHSvar', by(respond_health)
	}

foreach RHSvar in $RHScommon {
	des `RHSvar'
	ttest `RHSvar', by(respond_edu)
	}

*TABLE 2 - Jobs vs. Health

*All Households
areg jobs_v_health num_nonccial_private, absorb (comid) cluster(villageid)
areg jobs_v_health num_nonccial_private num_public num_ccial_private num_religious , absorb (comid) cluster(villageid)
areg jobs_v_health num_nonccial_private $RHScommon, absorb (comid) cluster(villageid)
*Kids Only
areg jobs_v_health num_nonccial_private if num_children>0, absorb (comid) cluster(villageid)
areg jobs_v_health num_nonccial_private num_public num_ccial_private num_religious if num_children>0, absorb (comid) cluster(villageid)
areg jobs_v_health num_nonccial_private $RHScommon if num_children>0, absorb (comid) cluster(villageid)

*TABLE 3 - Jobs vs. Education

*All HHs
areg jobs_v_edu num_nonccial_private, absorb (comid) cluster(villageid)
areg jobs_v_edu num_nonccial_private num_public num_ccial_private num_religious , absorb (comid) cluster(villageid)
areg jobs_v_edu num_nonccial_private $RHScommon, absorb (comid) cluster(villageid)
*HHs with children
areg jobs_v_edu num_nonccial_private if num_children>0, absorb (comid) cluster(villageid)
areg jobs_v_edu num_nonccial_private num_public num_ccial_private num_religious if num_children>0, absorb (comid) cluster(villageid)
areg jobs_v_edu num_nonccial_private $RHScommon if num_children>0, absorb (comid) cluster(villageid)

*APPENDIX TABLE:  INTERACTION WITH CHILD DUMMY INSTEAD OF SEPARATE CHILD-ONLY SUBSAMPLE ANALYSIS
	
gen child_dummy = 1 if num_children>0
	replace child_dummy=0 if num_children==0
	label var child_dummy "Child dummy = 1 if number of children > 0"
gen com_child = num_nonccial_private*child_dummy
	label var com_child "Number of community radios x Child dummy"
	
areg jobs_v_health num_nonccial_private child_dummy com_child , absorb (comid) cluster(villageid)
areg jobs_v_health num_nonccial_private child_dummy com_child num_public num_ccial_private num_religious , absorb (comid) cluster(villageid)
areg jobs_v_health num_nonccial_private child_dummy com_child $RHScommon_nokids, absorb (comid) cluster(villageid)
areg jobs_v_edu num_nonccial_private child_dummy com_child , absorb (comid) cluster(villageid)
areg jobs_v_edu num_nonccial_private child_dummy com_child num_public num_ccial_private num_religious , absorb (comid) cluster(villageid)
areg jobs_v_edu num_nonccial_private child_dummy com_child $RHScommon_nokids, absorb (comid) cluster(villageid)

*Table 4 PSACALC - selection on unobservables
	
tab comid, gen(comid_)
global communes "comid_1 comid_2 comid_3 comid_4 comid_4 comid_5 comid_6 comid_7 comid_8 comid_9 comid_10 comid_11 comid_12 comid_13 comid_14 comid_15 comid_16 comid_17 comid_18 comid_19 comid_20 comid_21 comid_22 comid_23 comid_24 comid_25 comid_26 comid_27 comid_28 comid_29 comid_30 comid_31 comid_32" 

reg jobs_v_health num_nonccial_private $RHScommon comid_*  , cluster(villageid)
	psacalc delta num_nonccial_private, mcontrol($communes)  rmax(.23)
	psacalc beta num_nonccial_private, mcontrol($communes)  rmax(.23) 
	
reg jobs_v_health num_nonccial_private $RHScommon comid_* if num_children>0, cluster(villageid)
	psacalc delta num_nonccial_private, mcontrol($communes)  rmax(.20)
	psacalc beta num_nonccial_private, mcontrol($communes)  rmax(.20) 

reg jobs_v_edu num_nonccial_private $RHScommon comid_*, cluster(villageid)
	psacalc delta num_nonccial_private, mcontrol($communes)  rmax(.16)
	psacalc beta num_nonccial_private, mcontrol($communes)  rmax(.16) 
	
reg jobs_v_edu num_nonccial_private $RHScommon comid_* if num_children>0, cluster(villageid)
	psacalc delta num_nonccial_private, mcontrol($communes)  rmax(.16)
	psacalc beta num_nonccial_private, mcontrol($communes)  rmax(.16) 

*TABLE 5 - GiftsPolicy vs. policy only

areg policygift_v_policy num_nonccial_private, absorb (comid) cluster(villageid)
areg policygift_v_policy num_nonccial_private num_public num_ccial_private num_religious , absorb (comid) cluster(villageid)
areg policygift_v_policy num_nonccial_private $RHScommon, absorb (comid) cluster(villageid)
areg policygift_v_policy num_nonccial_private if num_children>0, absorb (comid) cluster(villageid)
areg policygift_v_policy num_nonccial_private num_public num_ccial_private num_religious if num_children>0, absorb (comid) cluster(villageid)
areg policygift_v_policy num_nonccial_private $RHScommon if num_children>0, absorb (comid) cluster(villageid)

*RESULTS ROBUST TO CONTROLS FOR PERCEPTIONS OF GIFT-GIVING CANDIDATE (Reported in Text)
rename qm19_v_3_b_3 giftcand_corrupt
	gen giftcand_corrupt_new= 1 if giftcand_corrupt==1 
	replace giftcand_corrupt_new = 0 if giftcand_corrupt~=1
	
rename qm19_v_3_b_4 giftcand_delivers
	gen giftcand_delivers_new = 1 if giftcand_delivers==1 
	replace giftcand_delivers_new = 0 if giftcand_delivers~=1
	
areg policygift_v_policy num_nonccial_private giftcand*new, absorb (comid) cluster(villageid)
areg policygift_v_policy num_nonccial_private num_public num_ccial_private num_religious giftcand*new, absorb (comid) cluster(villageid)
areg policygift_v_policy num_nonccial_private giftcand*new $RHScommon, absorb (comid) cluster(villageid)
areg policygift_v_policy num_nonccial_private giftcand*new if num_children>0, absorb (comid) cluster(villageid)
areg policygift_v_policy num_nonccial_private num_public num_ccial_private num_religious giftcand*new if num_children>0, absorb (comid) cluster(villageid)
areg policygift_v_policy num_nonccial_private giftcand*new $RHScommon if num_children>0, absorb (comid) cluster(villageid)
	
*TABLE 6, MECHANISMS

*Listen to any community radio?
areg HH_lstn_priv_noncom num_nonccial_private $RHScommon, absorb(comid) cluster(villageid)
reg HH_lstn_priv_noncom num_nonccial_private $RHScommon, cluster(villageid)

*Are they more likely to listen to health and education programs?
areg listen_health_edu num_nonccial_private $RHScommon, absorb(comid) cluster(villageid)
reg listen_health_edu num_nonccial_private $RHScommon, cluster(villageid)

*Do they listen to more stations when more are available?
areg num_pvt_noncomm_radio_lstn num_nonccial_private $RHScommon, absorb(comid) cluster(villageid)
reg num_pvt_noncomm_radio_lstn num_nonccial_private $RHScommon, cluster(villageid)

*Are public affairs programs more important to them
areg pubaff_vimp num_nonccial_private $RHScommon, absorb(comid) cluster(villageid)
reg pubaff_vimp num_nonccial_private $RHScommon, cluster(villageid)

*TABLE 7:  Non PARAMETRIC ANALYSIS
	
gen num_nonccial_12 	= (num_nonccial_private <3)
gen num_nonccial_34 	= (num_nonccial_private >2 & num_nonccial_private <5)
gen num_nonccial_5plus 	= (num_nonccial_private >4)

areg jobs_v_health num_nonccial_34 num_nonccial_5plus 	$RHScommon, absorb (comid) cluster(villageid)
areg jobs_v_health num_nonccial_34 num_nonccial_5plus 	$RHScommon if num_children>0, absorb (comid) cluster(villageid)
areg jobs_v_edu  num_nonccial_34 num_nonccial_5plus 	$RHScommon , absorb (comid) cluster(villageid)
areg jobs_v_edu num_nonccial_34 num_nonccial_5plus 	$RHScommon if num_children>0, absorb (comid) cluster(villageid)
	
